package resources;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;

import javax.faces.bean.ManagedBean;

@ManagedBean(name = "editor")
public class Editor {

		private String value;
	 
		
	 
		/**
		 * @return the value
		 */
		public String getValue() {
			return value;
		}
		/**
		 * @param value the value to set
		 */
		public void setValue(String value) {
			this.value = value;
			System.out.println("yweey");
		}
		
		
		/*public void updateFile()
		{
			FileWriter stream  = null;
			try {
				stream = new FileWriter("/home/andrei/exam.pdf");
			} catch (IOException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}
			BufferedWriter buf = new BufferedWriter(stream);
			try {
				buf.write(getValue());
			} catch (IOException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}
			try {
				buf.close();
			} catch (IOException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}
		}*/
		public void updateFile()
		{
			if(value==null)return;
			FileWriter stream  = null;
			try {
				stream = new FileWriter("/home/andrei/exam.doc");
			} catch (IOException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}
			BufferedWriter buf = new BufferedWriter(stream);
			try {
				buf.write(getValue());
			} catch (IOException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}
			try {
				buf.close();
			} catch (IOException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}
		}
		
}
